﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// 独立旋转，在世界坐标系下旋转，不在乎玩家所在空间坐标系的位置
/// </summary>
[DisallowMultipleComponent]
public class BhvRotateAlone : MonoBehaviour
{
    [HideInInspector] public Vector3 angles;

    public float speed = 60;

    /// <summary>
    ///  同步旋转角度
    /// </summary>
    public void SyncAngles()
    {
        this.angles = this.transform.eulerAngles;
    }

    private void OnEnable()
    {
        this.SyncAngles();
    }

    // Update is called once per frame
    void Update()
    {
        angles += new Vector3(0, 1, 0) * speed * Time.deltaTime;
        this.transform.eulerAngles = angles;
    }
}
